package com.hx.company.service;


import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.ResponseBody;

import com.hx.company.UserInterface;
import com.hx.company.dao.MerDao;
import com.hx.company.dao.UserDao;
import com.hx.company.vo.Merchant;
import com.hx.company.vo.Order;
import com.hx.company.vo.User;
import com.hx.company.vo.UserLogin;

@Service("ui")
public class UserInerfaceImple  implements UserInterface{
	@Autowired(required=true)
	private UserDao ud;
	@Override
	@Transactional
	public int userRegister(User user,UserLogin ul) {
		
		return ud.addUser(user, ul);
	}

	@Override
	@Transactional
	public Boolean userLogin(UserLogin ul) {
		List<UserLogin> cs=new ArrayList<>();
		cs=ud.find(ul);
		Boolean i=false;
		for(UserLogin u:cs){
			if(u.getUpassword().equals(ul.getUpassword())){
				i=true;
			}
			
		}
		return i;
	}

	@Override
	@Transactional
	public List<Merchant> getMerchant() {
		
		
		return ud.findAll();
	}

	@Override
	public Boolean sendOrder(Order order) {
		
		return ud.addOrder(order);
	}

	@Override
	public Boolean getOrderMessage() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public Boolean sendEvaluate(String message) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public int addMerchant(Merchant m) {

		
		return 0;
	}
	
	
}
